<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue</title>
    <style>
        .v-enter,
        .v-leave-to {
            opacity: 0;
            transform: translateX(150px);
        }

        .v-enter-active,
        .v-leave-active {
            transition: all 1s ease;
        }
    </style>
</head>
<body>
<div id="app">
    <a href="#" @click.prevent="comName='reg'">reg</a>
    <a href="#" @click.prevent="comName='login'">login</a>
    <!-- 组件切换动画只需在组件外层增加transition标签即可 -->
    <!--transition 的mode属性定义动画顺序，不写动画可能出入顺序会同时进行，下面的mode定义先out再in-->
    <transition mode="out-in">
        <component :is="comName"></component>
    </transition>
</div>

<script src="https://unpkg.com/vue/dist/vue.js"></script>

<script>
    Vue.component('reg', {
        template: "<h2>register</h2>"
    });
    Vue.component('login', {
        template: "<h2>login</h2>"
    });
    var vm = new Vue({
        el: '#app',
        data: {
            comName: 'reg'
        },
        methods: {
        }
    });
</script>
</body>
</html>
